package com.lframework.starter.web.gen.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
import com.lframework.starter.web.gen.entity.GenDataObjQueryDetail;
import com.lframework.starter.web.gen.mappers.GenDataObjQueryDetailMapper;
import com.lframework.starter.web.gen.service.GenDataObjQueryDetailService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class GenDataObjQueryDetailServiceImpl extends
        BaseMpServiceImpl<GenDataObjQueryDetailMapper, GenDataObjQueryDetail> implements
        GenDataObjQueryDetailService {

    @Override
    public List<GenDataObjQueryDetail> getByObjId(String objId) {
        Wrapper<GenDataObjQueryDetail> queryWrapper = Wrappers.lambdaQuery(GenDataObjQueryDetail.class)
                .eq(GenDataObjQueryDetail::getDataObjId, objId)
                .orderByAsc(GenDataObjQueryDetail::getOrderNo);
        return this.list(queryWrapper);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void deleteByObjId(String objId) {
        Wrapper<GenDataObjQueryDetail> deleteWrapper = Wrappers.lambdaQuery(GenDataObjQueryDetail.class)
                .eq(GenDataObjQueryDetail::getDataObjId, objId);
        getBaseMapper().delete(deleteWrapper);
    }
}
